
// ref()对应 state
// computed() 对应 getters
// function() 对应 actions

import { ref, computed } from 'vue'
import { defineStore,storeToRefs } from 'pinia';

export const realdataStore = defineStore('realdata', () => {

  let sys_type = ref('0');  //0,1,2

  let test_arr = ref([11, 22, 33]);

  let sys_type_getter = computed(() => sys_type.value);

  function ch_sys_type(strings) {
    sys_type.value = strings
  }

  let data_12 = {
    deiviceId: 12,
    data: {
      PA: 1,
      time: 1
    }
  }

  let data_12_arr_x = ref([0, 0, 0, 0, 0, 0, 0, 0, 0])  //x轴；
  let data_12_arr_y = ref([0, 0, 0, 0, 0, 0, 0, 0, 0])  //y轴

  function ch_data_12_arr(vals_x,vals_y){
    data_12_arr_x.value.shift();
    data_12_arr_x.value.push(vals_x);

    data_12_arr_y.value.shift();
    data_12_arr_y.value.push(vals_y);

    console.log("ch_data_12_arr",data_12_arr_x,data_12_arr_y)
    
  }

  function ch_data_12(obj) {  //修改设备12的实时数据。
    data_12.value = obj;
  }


  return { sys_type, test_arr, sys_type_getter, data_12_arr_x, data_12_arr_y, ch_sys_type, ch_data_12,ch_data_12_arr }
})
